package com.example.tvrecyclerview.util;

import java.util.Collection;
import java.util.Iterator;

/**
 * @author: njb
 * @date: 2020/9/24 0024 0:59
 * @desc:
 */
public class Constants {
    public final static class key {
        public static final String mandarinType = "mandarinType";
        public static final String taiwaneseType = "taiwaneseType";
        public static final String phoneticType = "phoneticType";
        public static final String chineseKeyboard = "chineseKeyboard";
        public static final String phoneticCode = "phoneticCode";
        public static final String singerType = "singerType";
        public static final String singerName = "singerName";
        public static final String favouriteType = "favouriteType";
        public static final String songItem = "songItem";
        public static final String parentTitle = "parentTitle";
        public static final String childTitle = "childTitle";
        public static final String recordInfo = "recordInfo";
        public static final String needFocus = "isNeedFocus";
        public static final String songHistory = "songHistory";
        public static final String resetKey = "resetKey";
        public static final String bitmaps = "bitmaps";
    }

    public static final String EMPTY_STRING = "";

    public static String join(Collection collection, String separator) {
        if (collection == null) {
            return EMPTY_STRING;
        }
        Iterator iterator = collection.iterator();
        if (!iterator.hasNext()) {
            return EMPTY_STRING;
        }
        Object first = iterator.next();
        if (!iterator.hasNext()) {
            return first == null ? EMPTY_STRING : first.toString();
        }
        StringBuilder builder = new StringBuilder();
        if (first != null) {
            builder.append(first);
        }
        while (iterator.hasNext()) {
            if (separator != null) {
                builder.append(separator);
            }
            Object obj = iterator.next();
            if (obj != null) {
                builder.append(obj);
            }
        }
        return builder.toString();
    }
}
